<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/html/axios.min.js"></script>
    <script src="/html/ajax.js"></script>
    <script>
        function changeCode(){
            $("codeImg").src = "/checkCode?"+Math.random();
        }

        async function add(){
            var info = await ajaxGet("/session/add",{name:$("userName").value,userCode:$("code").value});
            if(info == "ok"){
                location.href = "/html/index.html";
            }
            else if(info == "codeError"){
                $("codeInfoDiv").innerHTML = "验证码错误";
            }
            else{
                alert("添加失败");
            }
        }
    </script>
</head>
<body>
    姓名：<input type="text" id="userName"><br>
    验证码：<img src="/checkCode" id="codeImg">
        <a href="javascript:changeCode()">看不清楚，换一张</a><br>
    请输入验证码：<input type="text" id="code">
    <div id="codeInfoDiv" style="color: red;font-size: 12px;"></div>
    <input type="button" value="添加" onclick="add()">
</body>
</html>